from sklearn.neighbors import KNeighborsClassifier

# 定义数据集
# 训练集
X = [
    [1, 2, 3],
    [2, 1, 3],
    [4, 2, 1]
]
# 目标值
y = [1, 2, 3]
# 定义训练模型
mediator = KNeighborsClassifier(n_neighbors=1)
# 训练
mediator.fit(X, y)
# 预测
rs = mediator.predict([[1, 3, 2]])
print(rs)
